import { getAuthorizationCodeUrl, getTokenInfo } from "@/util/net-disk/baidu/func";
import { redirect } from "next/navigation";

export async function GET() {
    const tokenInfo = await getTokenInfo();
    if (tokenInfo) {
      const url = `https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo&access_token=${tokenInfo.access_token}`;
      const result = await fetch(url);
      const text = await result.text();
      return new Response(text, {
        headers: {
          "Content-Type": result.headers.get("Content-Type") || "text/plain",
        },
      });
    }
    return redirect(getAuthorizationCodeUrl());
}